package com.briup.cloud.framework.logging.service.impl;

import com.briup.cloud.framework.logging.bean.BaseLogging;
import com.briup.cloud.framework.logging.mapper.BaseLoggingMapper;
import com.briup.cloud.framework.logging.service.ILoggingService;
import com.briup.cloud.framework.logging.web.vm.LogParam;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author guomiao
 * @Date 2022/3/4 6:20
 */
@Service
public class LoggingServiceImpl implements ILoggingService {
    @Autowired
    private BaseLoggingMapper loggingMapper;

    public PageInfo<BaseLogging> findAllByPage(int pageNum, int pageSize){
        PageHelper.startPage(pageNum, pageSize);
        List<BaseLogging> list =loggingMapper.selectAll();
        return new PageInfo<>(list);
    }


    public PageInfo<BaseLogging> findByCondition(LogParam param){
        PageHelper.startPage(param.getPageNum(),param.getPageSize());
        List<BaseLogging> list = loggingMapper.selectByCondition(param);
        return new PageInfo<>(list);
    }

    @Override
    public void save(BaseLogging logging) {
        loggingMapper.insert(logging);
    }
}
